/**
 * 
 */
package data;

/**
 * The pagination for retrieving data.
 * 
 * @author chuxiaoyuan
 *
 */
public class Pagination {

	/**
	 * Constructor.
	 */
	public Pagination() {
		// 
	}
	
	/**
	 * Constructor.
	 */
	public Pagination(int pageSize, int pageNo) {
		this.setPageNo(pageNo);
		this.setPageSize(pageSize);
	}

	/**
	 * The page number (starts with 1).
	 */
	private int pageNo;
	
	/**
	 * The page size (number of records in a page).
	 */
	private int pageSize;

	/**
	 * Get the page number (starts with 1)
	 * 
	 * @return the pageNo
	 */
	public int getPageNo() {
		return pageNo;
	}

	/**
	 * Set the page number (starts with 1)
	 * 
	 * @param pageNo the pageNo to set
	 */
	public void setPageNo(int pageNo) {
		if (pageNo <= 0) {
			throw new IllegalArgumentException(
					"Pagination page No must be started from 1.");
		}
		this.pageNo = pageNo;
	}

	/**
	 * Get the page size (number of records in a page).
	 * 
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * Set the page size (number of records in a page).
	 * 
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		if (pageSize <= 0) {
			throw new IllegalArgumentException(
					"Pagination size must be greater than 0.");
		}
		this.pageSize = pageSize;
	}

}
